﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GMS.BIZ;

public partial class Information_TeaInformation : System.Web.UI.Page
{
    protected void Page_LoadComplete(object sender, EventArgs e)
    {
        if (((Account)Session["Account"]).RoleCurrent.Equals('s')) Response.Redirect("Default.aspx");
        //拿Account中得currentRole
        Account myAccount = (Account)Session["Account"];
        Staff myStaff = new Staff();
        switch (myAccount.RoleCurrent)
        {
            case 'a': myStaff = (Admin)Session["Admin"]; break;
            case 'c': myStaff = (ClassTeacher)Session["ClassTeacher"]; break;
            case 't': myStaff = (Teacher)Session["Teacher"]; break;
            default: Response.Redirect("~/"); break;
        }

        Staff myTeacher = myStaff;
        if (myTeacher.TeacherName == "")
        {
            //Response.Redirect("TeaInformation.aspx");
            Label_completeinfo.Visible = true;
        }
        else Label_completeinfo.Visible = false;
        Label_tchid.Text = myTeacher.TeacherId;
        Label_tchname.Text = myTeacher.TeacherName;
        Label_tchgender.Text = myTeacher.TeacherGender;
        Label_tchoffice.Text = myTeacher.TeacherOffice;
        Label_tchofficetel.Text = myTeacher.TeacherOfficeTel;
        Label_tchmobile.Text = myTeacher.TeacherMobile;
        Label_tchmail.Text = myTeacher.TeacherMail.ToString();
        Label_tchaward.Text = myTeacher.TeacherAward;
        Label_tchfield.Text = myTeacher.TeacherField;
        Label_tchtitle.Text = myTeacher.TeacherTitle;
        if (myTeacher.IfTeacher)
            Label_iftch.Text = "是";
        else Label_iftch.Text="否";
        if (myTeacher.IfClassTeacher)
            Label_ifctch.Text = "是";
        else Label_ifctch.Text = "否";

        switch (myAccount.RoleCurrent)
        {
            case 'a': Label1_nowRole1.Text = "管理员"; break;
            case 't': Label1_nowRole1.Text = "教师"; break;
            case 'c': Label1_nowRole1.Text = "班主任"; break;
            default: break;
        }

        if (myAccount.RoleList.Contains("t"))
            ImageButton_transtch.Visible = true;
        if (myAccount.RoleList.Contains("c"))
            ImageButton_transctch.Visible = true;
        if (myAccount.RoleList.Contains("a"))
            ImageButton_transadmin.Visible = true;
    }

    protected void Image_PersonalInfo_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("TeaInformationEdit.aspx");
    }

    protected void ImageButton_transctch_Click(object sender, ImageClickEventArgs e)
    {
        Account myAccount = (Account)Session["Account"];
        string ok = myAccount.ChangeCurrentRole('c');
        if (ok.CompareTo(Resources.ErrorMessage.OK) == 0)
            Label_result.Text = "角色状态转化成功";
        else
            Label_result.Text = "角色状态转化未成功";
    }

    protected void ImageButton_transtch_Click(object sender, ImageClickEventArgs e)
    {
        Account myAccount = (Account)Session["Account"];
        string ok = myAccount.ChangeCurrentRole('t');
        if (ok.CompareTo(Resources.ErrorMessage.OK) == 0)
            Label_result.Text = "角色状态转化成功";
        else
            Label_result.Text = "角色状态转化未成功";
    }

    protected void ImageButton_transadmin_Click(object sender, ImageClickEventArgs e)
    {
        Account myAccount = (Account)Session["Account"];
        string ok = myAccount.ChangeCurrentRole('a');
        if (ok.CompareTo(Resources.ErrorMessage.OK) == 0)
            Label_result.Text = "角色状态转化成功";
        else
            Label_result.Text = "角色状态转化未成功";
    }
}
